/**
 * 
 */
package com.fang.www.join.one;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

/**
 * @author ����
 *
 */
public class JoinOneJob {
public static void main(String[] args) throws IllegalArgumentException, IOException, ClassNotFoundException, InterruptedException {
	Configuration configuration = new Configuration();
	Job job = new Job(configuration,"sort-job");
	job.setJarByClass(JoinOneJob.class);
    Configuration.addDefaultResource("core-site.xml");
	job.setMapperClass(JoinOneMapper.class);
	job.setMapOutputKeyClass(Text.class);
	job.setMapOutputValueClass(Employee.class);
	
	job.setReducerClass(JoinOneReducer.class);
	job.setOutputKeyClass(NullWritable.class);
	job.setOutputValueClass(Text.class);
//	job.setNumReduceTasks(2);
	//                                          hdfs://ffl-o-hadoop04:8020
	FileInputFormat.addInputPath(job, new Path("hdfs://ffl-o-hadoop04:8020/wg/joinOne/*"));
	FileSystem fs = FileSystem.get(configuration);
	Path outputDir = new Path("hdfs://ffl-o-hadoop04:8020/wg/joinOne/output");
	
	if(fs.exists(outputDir)){
		fs.delete(outputDir, true);
	}
	FileOutputFormat.setOutputPath(job, outputDir);
	System.exit(job.waitForCompletion(true)?0:1);
}
}
//���� Configuration.addDefaultResource("core-site.xml"); ������þ����ܲ���hdfs��
//���ö��NumReduceTasks ��ô���ʼ������SortedReducer����,��ô��ʼ���Ķ�����������������Բ���������Ҫ��ʼ��1��